package com.wbt.spring.support.dao;

import com.wbt.common.beans.User;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

@Component
public class UsersDao implements InitializingBean , SmartInitializingSingleton {

    private User user;

    @Autowired
    private List<User> userList;

    public UsersDao(){
        System.out.println("UserDao 构造.......");
        user = new User();
        user.setId("0");
        user.setUserName("张三");
        user.setAge(22);
        user.setWork("架构师");
    }

    public User getUser(){
        return user;
    }

    public List<User> getUserList(){
        return userList;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("UserDao afterPropertiesSet.......");
    }

    @PostConstruct
    public void postConstruct(){
        System.out.println("UserDao postConstruct.......");
    }

    @Override
    public void afterSingletonsInstantiated() {
        System.out.println("UserDao afterSingletonsInstantiated.......");
    }
}
